package com.xingdata.jjxc;

import java.io.File;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

public class VideoPlaybackActivity extends Activity {
	private VideoView videoplayback;
	private MediaController mediaController;
	private TextView title;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.video_playback);
		videoplayback = (VideoView) findViewById(R.id.videoplayback);
		title = (TextView) findViewById(R.id.title);
		title.setText("播放视频");
		initvideoplayer();
	}

	private void initvideoplayer() {
		mediaController = new MediaController(this);
		File file = new File("/mnt/sdcard/xiaomaolv.3gp");
		if (file.exists()) {
			videoplayback.setVideoPath(file.getAbsolutePath());
			videoplayback.setMediaController(mediaController);
			mediaController.setMediaPlayer(videoplayback);
			videoplayback.requestFocus();
			videoplayback.start();
			videoplayback
					.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

						@Override
						public void onCompletion(MediaPlayer mp) {
							// TODO Auto-generated method stub

						}
					});
		}
	}
}
